package com.zhxq.ai.config;

import com.alibaba.dashscope.audio.asr.recognition.RecognitionParam;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class ParaformerConfiguration {

    @Value("${alibailian.apiKey}")
    private String apiKey;

    @Value("${alibailian.Paraformer.model}")
    private String model;

    @Value("${alibailian.Paraformer.format}")
    private String format;

    @Bean
    public RecognitionParam recognitionParam() {
        // 请求参数
        return RecognitionParam.builder()
           // 若没有将API Key配置到环境变量中，需将下面这行代码注释放开，并将apiKey替换为自己的API Key
           .apiKey(apiKey)
           .model(model)
           .format(format)
           .sampleRate(16000)
           // “language_hints”只支持paraformer-realtime-v2模型
           .parameter("language_hints", new String[]{"zh", "en"})
           .parameter("task_group", "audio_asr_task")
           .build();
    }
}
